package com.xiaoshuidi.cloud.module.member.convert.feedback;


import com.xiaoshuidi.cloud.module.member.controller.admin.feedback.vo.MemberFeedbackExportVO;
import com.xiaoshuidi.cloud.module.member.controller.admin.feedback.vo.MemberFeedbackGetRespVO;
import com.xiaoshuidi.cloud.module.member.controller.admin.feedback.vo.MemberFeedbackPageRespVO;
import com.xiaoshuidi.cloud.module.member.controller.app.feedback.vo.HistoricalFeedbackRespVO;
import com.xiaoshuidi.cloud.module.member.enums.FeedbackStatusEnum;
import com.xiaoshuidi.cloud.module.member.pojo.feedback.MemberFeedback;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface MemberFeedbackConvert {
    MemberFeedbackConvert INSTANCE = Mappers.getMapper(MemberFeedbackConvert.class);

    List<MemberFeedbackPageRespVO> convertList(List<MemberFeedback> records);

    MemberFeedbackGetRespVO convert(MemberFeedback memberFeedback);

    List<MemberFeedbackExportVO> convert(List<MemberFeedbackPageRespVO> memberFeedbackPageRespVOS);
    static List<MemberFeedbackExportVO> convertToExport(List<MemberFeedbackPageRespVO> memberFeedbackPageRespVOS){
        if ( memberFeedbackPageRespVOS == null ) {
            return null;
        }

        List<MemberFeedbackExportVO> list = new ArrayList<MemberFeedbackExportVO>( memberFeedbackPageRespVOS.size() );
        for ( MemberFeedbackPageRespVO memberFeedbackPageRespVO : memberFeedbackPageRespVOS ) {
            list.add( toMemberFeedbackExportVO( memberFeedbackPageRespVO ) );
        }

        return list;
    }

    static MemberFeedbackExportVO toMemberFeedbackExportVO(MemberFeedbackPageRespVO memberFeedbackPageRespVO) {
        if ( memberFeedbackPageRespVO == null ) {
            return null;
        }

        MemberFeedbackExportVO memberFeedbackExportVO = new MemberFeedbackExportVO();

        memberFeedbackExportVO.setUserName( memberFeedbackPageRespVO.getUserName() );
        memberFeedbackExportVO.setMobile( memberFeedbackPageRespVO.getMobile() );
        memberFeedbackExportVO.setApartmentName( memberFeedbackPageRespVO.getApartmentName() );
        memberFeedbackExportVO.setFeedback( memberFeedbackPageRespVO.getFeedback() );
        memberFeedbackExportVO.setCreateTime( memberFeedbackPageRespVO.getCreateTime() );
        memberFeedbackExportVO.setStatus(FeedbackStatusEnum.getNameByCode(memberFeedbackPageRespVO.getStatus()) );
        memberFeedbackExportVO.setProcessor( memberFeedbackPageRespVO.getProcessor() );
        memberFeedbackExportVO.setProcessingTime( memberFeedbackPageRespVO.getProcessingTime() );
        memberFeedbackExportVO.setProcessingProgram( memberFeedbackPageRespVO.getProcessingProgram() );

        return memberFeedbackExportVO;
    }
}
